package com.qk.management.config;

import com.qk.constant.TaskConstant;
import com.qk.management.service.impl.AvatarCleanServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

/**
 *  定时任务
 */
@Slf4j
@Configuration
@EnableScheduling
@RequiredArgsConstructor
public class ScheduledTasksConfig {

    private final AvatarCleanServiceImpl avatarCleanupServiceImpl;

    @Scheduled(cron = TaskConstant.CLEAN_AVATAR_TASK)
    public void executeTask() {
        log.info("oss垃圾文件清理开始执行：{}", LocalDateTime.now());
        avatarCleanupServiceImpl.executeAvatarCleanup();
    }
}